//
//  FlutterActivityIndicator.m
//  activity_indicator
//
//  Created by admin_test on 2019/1/8.
//

#import "FlutterActivityIndicator.h"
#import "BaseMapView.h"
#import "AddIosView.h"
@implementation FlutterActivityIndicatorFactory{
    NSObject<FlutterBinaryMessenger>*_messenger;
}

- (instancetype)initWithMessenger:(NSObject<FlutterBinaryMessenger> *)messager{
    self = [super init];
    if (self) {
        _messenger = messager;
    }
    return self;
}

-(NSObject<FlutterMessageCodec> *)createArgsCodec{
    return [FlutterStandardMessageCodec sharedInstance];
}

-(NSObject<FlutterPlatformView> *)createWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id)args{
    
   FlutterActivityIndicatorController*activity = [[FlutterActivityIndicatorController alloc] initWithWithFrame:frame viewIdentifier:viewId arguments:args binaryMessenger:_messenger];
    
    return activity;
    
}

@end

@implementation FlutterActivityIndicatorController{
    FlutterMethodChannel* _channel;
    AddIosView *addIosView;
}
- (instancetype)initWithWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id)args binaryMessenger:(NSObject<FlutterBinaryMessenger> *)messenger{
    if ([super init]) {
        self.view.backgroundColor = [UIColor grayColor];
        addIosView = [[AddIosView alloc]initWithFrame:frame AndMsg:args];

//
//        _channel = [FlutterMethodChannel methodChannelWithName:@"ahaTravel.com/mapInteraction" binaryMessenger:messenger];
//        __weak __typeof__(self) weakSelf = self;
//        [_channel setMethodCallHandler:^(FlutterMethodCall *  call, FlutterResult  result) {
//            [weakSelf onMethodCall:call result:result];
//        }];
        
    }
    return self;
}

-(UIView *)view{
    return addIosView;
}

-(void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result{
    [addIosView callMethod:[call method] AndMsg:call.arguments result:result];
}


@end


